package com.RedRiver.hospitalsystem.finance_service.app.controller;


import cn.hutool.core.bean.BeanUtil;
import com.RedRiver.hospitalsystem.finance_service.client.BillDetailClient;
import com.RedRiver.hospitalsystem.finance_service.client.param.FindBillAllInfoClient;
import com.RedRiver.hospitalsystem.finance_service.client.param.FindBillDetailInfoClient;
import com.RedRiver.hospitalsystem.finance_service.client.param.FindBillDetailInfoListClient;
import com.RedRiver.hospitalsystem.finance_service.client.param.FindBillDetailInfoListXiClient;
import com.RedRiver.hospitalsystem.finance_service.common.WoniuxyBeanCopyUtil;
import com.RedRiver.hospitalsystem.finance_service.infra.model.Bill;
import com.RedRiver.hospitalsystem.finance_service.service.BillDetailService;
import com.RedRiver.hospitalsystem.finance_service.service.info.FindBillDetailInfo;
import com.RedRiver.hospitalsystem.finance_service.service.info.FindBillDetailInfoList;
import com.RedRiver.hospitalsystem.finance_service.service.info.FindBillDetailInfoXiList;
import com.RedRiver.hospitalsystem.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 龙世超
 * @since 2022-04-26
 */
@RestController
@RequestMapping("/billDetail")
@Api(tags = "账单详情")
public class BillDetailController implements BillDetailClient {

    @Resource
    private BillDetailService billDetailService;
    //根据账单id查账单详情
    @ApiOperation("根据账单id查账单详情")
    @GetMapping("/findBillDetailById")
    public Result<FindBillDetailInfoListClient> findBillDetailById(@ApiParam("请输入账单id") @RequestParam("id")Integer id) {
        FindBillDetailInfoList findBillDetailInfo = billDetailService.findBillDetailById(id);
        FindBillDetailInfoListClient byIdInfo = BeanUtil.copyProperties(findBillDetailInfo,FindBillDetailInfoListClient.class);
        return Result.getInstance(FindBillDetailInfoListClient.class).setData(byIdInfo);
    }


    //根据账单id查账单详情详细
    @ApiOperation("根据账单id查账单详情")
    @GetMapping("/findBillDetailByIdXi")
    public Result<FindBillDetailInfoListXiClient> findBillDetailByIdXi(@ApiParam("请输入账单id") @RequestParam("id")Integer id) {
        FindBillDetailInfoXiList findBillDetailInfoXiList = billDetailService.findBillDetailByIdXi(id);
        FindBillDetailInfoListXiClient byIdInfo = WoniuxyBeanCopyUtil.copyone(findBillDetailInfoXiList,FindBillDetailInfoListXiClient.class);
        return Result.getInstance(FindBillDetailInfoListXiClient.class).setData(byIdInfo);
    }
}

